$(function () {
    var form = new xhForm($('#xh_form'));
    form.parse();

    $('[name=iChiefId]').select2();
    $('[name=iSubject]').select2();
    $('[name="sChargeIds[]"]').select2();

    if(info != undefined){
        form.fill(info);
        $('[name=iChiefId]').val(info['iChiefId']).trigger('change');
        $('[name=iSubject]').val(info['iSubject']).trigger('change');
        if(info['iLevel']==2){
            $('[name="sChargeIds[]"]').val(info['sChargeIds'].split(',')).trigger('change');
        }
    }

    $('#bt_modal_confirm',parent.document).click(function () {
        form.submit('school_book/saveGroup',{},function (res) {
            window.top.xhTop.showSuccess(res.msg);
            window.top.xhTop.closeModal();
            window.top.xhTop.getActiveFrame().frames['tabFrame']['groupFrame'].obj.groupTree.treegrid('reload');
        })
    });



});
